﻿using Ivory;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using DefCore.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using DefCore.Mapping;
using DefCore;
using DefCore.Tools;
using Krypton.Lights;
using DefCore.Structures;

namespace Defender.Framework
{
    public enum CellState { Open, Closed }

    public sealed class Cell : CellBase
    {
        public override bool IsBuildable
        {
            get { return State == CellState.Open; }
        }
        public override bool IsWalkable
        {
            get { return State == CellState.Open; }
        }

        public override CellFrameType ValidFrameTypes
        {
            get
            {
                if(IsBuildable)
                    return DefCore.Structures.CellFrameType.SEMIFRAME;

                return 0;
            }
        }
        public CellState State { get; set; }
        public override bool IsSelectable
        {
            get
            {
                return false;
            }
            protected set { }
        }

        //ctor
        public Cell(DungeonPos pos)
             : base(pos)
        {
            State = CellState.Closed;            
        }

        //Methods
        protected override void DrawCell(SpriteBatch batch, Rectangle drawingRect)
        {
            batch.Draw(TileBin.Instance.GetTile(
                (int)(State == CellState.Open ? 
                CellConverterEnum.Open : CellConverterEnum.Closed)), 
                drawingRect, Color.White);
        }
        protected override void SolveCell(InputControl control, GameTime time)
        {

        }
    }
}
